package com.ssy.lingxi.system.config.interceptor;

import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

//@EnableWebMvc
//@Configuration
public class WebAppConfig extends WebMvcConfigurerAdapter {

    //将拦截器注入容器
   // @Bean
    LoginInterceptor loginInterceptor(){
        return new LoginInterceptor();
    }

    /**
     * 配置拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //这里参数是一个实现了HandlerInterceptor接口的拦截器
        registry.addInterceptor(loginInterceptor())
                .addPathPatterns("/**")//需要拦截的请求
                .excludePathPatterns("/init/**", "/middleground/user/login","/swagger-ui.html");//不拦截的请求

    }
}

